File transfer is commonly performed by computer applications that access disk drives. The general file transfer methods from a local drive to a redundant array of disks (RAID) controller include, but are not limited to, Ethernet protocol, Fibre channel protocol, small computer system interface (SCSI) protocol, and serial port (X/Z) modem protocol. Although considerably slower than other aforementioned methods, serial port file transfer via modems often is indispensable during software development, especially when other methods are not functional or available. In the current development of RAID controller firmware, various terminal emulation programs may be used for file transfer. Useable terminal emulation programs include ProComm Plus, HyperTerminal, Tera Term, and the like. These terminal emulation programs are extensively used during product test and verification because of their user friendly interface and powerful test script handling ability.
When a flash file is transferred from a host's local storage medium (e.g., disk drive) to the RAID controller by the Xmodem file transfer protocol, three steps are generally performed (as shown in FIG. 5): 1) the transfer of the flash file from the host's local medium to the RAID controller's buffer memory (505 to 510); 2) the adjustment of the flash file size in buffer (i.e., the resetting the pointer to the end of file) and removal of file transfer protocol patched data bytes 515; and 3) the writing of the flash file (with adjusted size) from the RAID controller's buffer to its flash chip 520. The flash size increases by 0 to 127 bytes for 128-modem or by 0 to 1023 bytes for a 1K-modem during the file transfer process because of the data-patch transfer protocol. For a 128-byte modem, because 128*M is always greater than N by 0 (only when N is a multiple of 128) to 127 bytes, an Xmodem file transfer protocol patches these bytes with a certain data pattern—usually 0×1A. Different terminal emulation programs may not interpret in the same way the file transfer protocol byte pattern patched at the end of the transfer file data.
The relationship between flash file size of N bytes and the number M of data word transfers may be obtained as follows:If (N/128=0)M=(int)N/128;ElseM=(int)N/128+1;
In most cases, N is not divisible by 128, so M would normally be (N/128+1). The additional data may cause the data integrity to be lost in terms of the flash file size. In fact, there is no effective way to know the original flash file size during the Xmodem file transfer since the end of file (EOF) indicator (if any) of the flash file may not be transferred with the file itself. The size of the flash file transferred to buffer memory may be determined later from the number of transfers (which is M) after the flash file transfer to the RAID controller terminates.
The file transfer protocol normally patches a pattern (e.g., 0×1A) at the end of the data file if the original file size is not a multiple of 128 bytes. However, the terminal emulation program (e.g., ProComm Plus) may recognize a different pattern such as 0×00. Other incompatibilities may be encountered such that the terminal emulation program (e.g., ProComm Plus) may not be the only software entity that violates the file transfer protocol (e.g., Xmodem).
Assuming the file transfer protocol patched pattern is PQ, the patched pattern may vary according to the terminal emulation program used (e.g., PQ may be 0×1A or 0×00 or the like based on the memory dump of the transferred files, depending upon whether the Xmodem protocol is followed). It is necessary to check the end of the buffered flash file for the data pattern. If the last byte data is LS, the end of the flash file is searched backward until the first byte of non-LS data is encountered. If there are multiple occurrences of LS, then there is a strong probability that LS is the data patched by the file transfer protocol. When the original flash file size is exactly a multiple of 128 bytes, this algorithm will probably fail since there is no X modem patched data.
As shown in FIG. 5, a current solution is to compare the last bytes of data of the transferred flash file (in RAID controller's buffer memory) against a standard patch pattern (e.g., 0×1A). If they match consecutively, then the data will be removed from the end of the transferred flash file and the flash file length will be decreased by the corresponding number of bytes that are removed. During this “data peeling” process (step 2), the flash file size is adjusted internally in the controller's buffer and the “new” flash file is then written to the flash chip (step 3).
Two problems arise when flash file transfers are performed using the file transfer protocol for personal computers through the above three step approach:                1) If the last byte or a few bytes of the original flash file matches the data pattern patched by the file transfer protocol (e.g., 0×1A as may be used by Xmodem), then these data bytes will be unnecessarily removed, as demonstrated in FIG. 6);        2) If the terminal emulation program violates the file transfer protocol data patch (e.g., ProComm Plus patches 0×00), then the patched data will not be removed by checking against standard file transfer protocol patch pattern (e.g., FIG. 7).        
The first case causes loss of information. The second case causes erroneous data (i.e., the patched data) to become part of the transferred flash file. In both cases, the integrity of information is lost, and the system may not boot up properly when the control processor tries to fetch data from the controller flash after a power cycle or reboot operation.
Therefore, it would be desirable to provide a method and system to maintain data integrity during flash file transfer to a RAID controller flash memory using a terminal emulation program.